<!--
 * @Description: 
 * @Author: xiongkuobiao
 * @Date: 2023-04-12 10:02:14
 * @LastEditors: xiongkuobiao
 * @LastEditTime: 2023-04-17 10:20:15
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // call,apply,bind




        // let obj = { name: 111 }


        // Function.prototype.myCall = function (obj, ...args) {
        //     let key = Symbol()
        //     obj[key] = this
        //     let result = obj[key](...args)
        //     delete obj[key]
        //     return result
        // }


        // Function.prototype.myApply = function (obj, args) {
        //     let key = Symbol()
        //     obj[key] = this
        //     let result = obj[key](...args)
        //     delete obj[key]
        //     return result
        // }

        // Function.prototype.myApply = function (obj, ...args) {
        //     let key = Symbol()
        //     obj[key] = this
        //     return function (...args1) {
        //         let result = obj[key](...args, ...args1)
        //         delete obj[key]
        //         return result
        //     }
        // }



        // function fn(...args) {
        //     console.log(this.name, args);
        // }
        // fn.myApply(obj, 1, 2, 3)(1, 2, 3)
        // let aa = new fn()




        // function father() {
        //     this.name = "father"
        //     this.age = 50
        //     this.list = [1, 2, 3]
        //     this.obj = { tool: 1111 }
        // }

        // function child() {

        // }
        // // 原型链继承
        // child.prototype = new father()
        // let chi1 = new child()
        // let chi2 = new child()

        // chi1.list.push(11111111111)
        // chi1.name = '1111111111111111111'
        // console.log(chi1, chi2);


        function father() {
            this.name = "father"
            this.age = 50
            this.list = [1, 2, 3]
            this.obj = { tool: 1111 }
        }

        function child() {
            father.call(this)
        }
        // 原型链继承
        child.prototype = Object.create(father.prototype, {
            constructor: {
                value: child,
                configurable: true,
                enumerable: false,
                writable: true
            }
        })
        let chi1 = new child()
        let chi2 = new child()

        chi1.list.push(11111111111)
        chi1.name = '1111111111111111111'
        console.log(chi1, chi2);








    </script>
</body>

</html>